package com.blb.mapper.impl;

import com.blb.mapper.UserDAO;
import com.blb.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class UserDAOImpl implements UserDAO {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public User selectUserByUsername(String username) {
        User user = jdbcTemplate.queryForObject("select * from t_user where username = ?",
                new BeanPropertyRowMapper<>(User.class), username);
        return user;
    }
}
